﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using Journeo_backend.Models.GPT;
using Microsoft.AspNetCore.Authorization;

namespace Journeo_backend.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    [AllowAnonymous]
    public class GptController : ControllerBase
    {
        private readonly IGptService _gptService;

        public GptController(IGptService gptService)
        {
            _gptService = gptService;
        }

        [HttpPost("simple-chat")]
        [SwaggerOperation(Summary = "简单对话", Description = "通过用户消息进行简单对话")]
        [SwaggerResponse(200, "对话成功", typeof(Response<SimpleChatResponse>))]
        [SwaggerResponse(400, "对话失败，用户消息无效")]
        public async Task<IActionResult> SimpleChat(SimpleChatRequest request)
        {
            var response = await _gptService.SimpleChat(request);
            return Ok(response);
        }

        [HttpPost("travel-recommend")]
        [SwaggerOperation(Summary = "旅游推荐", Description = "通过用户消息进行旅游推荐")]
        [SwaggerResponse(200, "推荐成功", typeof(Response<TravelRecommendResponse>))]
        [SwaggerResponse(400, "推荐失败，用户消息无效")]
        public async Task<IActionResult> GetTravelRecommendations(TravelRecommendRequest request)
        {
            var response = await _gptService.GetTravelRecommendations(request);
            return Ok(response);
        }

        [HttpPost("spot-analysis")]
        [SwaggerOperation(Summary = "景点分析", Description = "通过用户消息进行景点分析")]
        [SwaggerResponse(200, "分析成功", typeof(Response<SpotAnalysisResponse>))]
        [SwaggerResponse(400, "分析失败，用户消息无效")]
        public async Task<IActionResult> AnalyzeSpots(SpotAnalysisRequest request)
        {
            var response = await _gptService.AnalyzeSpots(request);
            return Ok(response);
        }

        [HttpPost("continuous-chat")]
        [SwaggerOperation(Summary = "连续对话", Description = "通过用户消息进行连续对话")]
        [SwaggerResponse(200, "对话成功", typeof(Response<SimpleChatResponse>))]
        [SwaggerResponse(400, "对话失败，用户消息无效")]
        public async Task<IActionResult> ContinuousChat(ContinuousChatRequest request)
        {
            var response = await _gptService.ContinuousChat(request);
            return Ok(response);
        }
    }
}
